package com.ruoyi.common.core.controller;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil;

/**
 * @Description
 * @Author caiyanshan
 * @Date 2021/4/16 16:11
 * @Param
 * @Return
 */
public class BaseService {
  /**
   * 设置请求分页数据
   */
  protected void startPage()
  {
    PageDomain pageDomain = TableSupport.buildPageRequest();
    Integer pageNum = pageDomain.getPageNum();
    Integer pageSize = pageDomain.getPageSize();
    if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
    {
      String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
      PageHelper.startPage(pageNum, pageSize, orderBy);
    }
  }
}
